package mashuaiproject.mashuaiproject.mapper;

import mashuaiproject.mashuaiproject.model.clickfabulou;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

@Component
public interface FabulousMapper {

    @Select("select *from clickfabulou where comment_id=#{fatherId}")
    clickfabulou selectOneFabulous(@Param("fatherId") Integer fatherId);

    @Insert("insert into clickfabulou (fabulous_up, fabulous_down, comment_id, user_id, gmt_create, gmt_modified,quesionid) values(" +
            "#{fabulous_up},#{fabulous_down},#{comment_id},#{user_id},#{gmt_create},#{gmt_modified},#{quesionid})")
    int insertfabulous1(clickfabulou fabulous);

    @Update("update clickfabulou  set fabulous_up=#{staues} where comment_id=#{comment_id}")
    void updatefabulous(@Param("comment_id") Integer fatherId,@Param("staues")String staues);

    @Update("update  clickfabulou set  fabulous_down=#{staues} where comment_id=#{comment_id}")
    void updatefabulouDown(@Param("comment_id") Integer fatherId,@Param("staues")String staues);


    @Select("select fabulous_up from comment where id=#{id}")
    Integer selectFabulous_up(@Param("id") Integer fatherId);
    @Select("select fabulous_down from comment where id=#{id}")
    Integer selectFabulous_down(@Param("id") Integer fatherId);

    //up点赞加1
    @Update("update  comment set  fabulous_up=fabulous_up+1 where id=#{id}")
    void updateUpCommentFabulous(@Param("id") Integer fatherId);
    //up点赞-1
    @Update("update  comment set  fabulous_up=fabulous_up-1 where id=#{id}")
    void updateUpCommentFabulousReduce(@Param("id") Integer fatherId);

    @Update("update  comment set  fabulous_down=fabulous_down+1 where id=#{id}")
    void updateDownCommentFabulous(@Param("id") Integer fatherId);
    //up点赞-1
    @Update("update  comment set  fabulous_down=fabulous_down-1 where id=#{id}")
    void updateDownCommentFabulousReduce(@Param("id") Integer fatherId);


}
